--#include "data\config\hero\HeroGodWeaponConfig.lua" once

--nGwType1:神兵 2：神盾 =tagHeroProperty
function HeroGodWeaponLevelUp(sysarg, nGwType)
	local typeCfg = HeroGodWeaponConfig[nGwType]
	if not typeCfg then
		Actor.sendTipmsg(sysarg, Lang.ScriptTips.COM0001, ttFlyTip)
		return 
	end

	if not Actor.checkActorLevel(sysarg, typeCfg.activeLevel[2], typeCfg.activeLevel[1]) then
		Actor.sendTipmsg(sysarg, Lang.ScriptTips.COM0016,ttFlyTip)
		return
	end

	local nGwLevel =  Hero.getHeroProperty(sysarg, -1, nGwType)
	if nGwType == 2 and nGwLevel <= 0 then
		if not IsGodShieldBossFinish(sysarg) then
			Actor.sendTipmsg(sysarg, Lang.ScriptTips.GodWeapon002, ttFlyTip)
			return
		end
	end
	print("nGwLevel = "..nGwLevel)
	if nGwLevel >= #typeCfg.Consumes then
		Actor.sendTipmsg(sysarg, Lang.ScriptTips.GodWeapon001, ttFlyTip)
		return
	end
	if not CheckConsumeCond(sysarg, typeCfg.Consumes[nGwLevel+1]) then
		return
	end
	if not DoConsumeCond( sysarg, typeCfg.Consumes[nGwLevel+1], 1, LogIds.GodWeaponUpLevelLogId, Lang.LogTips.GodWeaponLevelUp ) then
		return
	end
	Hero.setHeroProperty(sysarg, -1, nGwType, nGwLevel + 1)
	if nGwLevel == 0 then
		local noticeStr = string.format(Lang.ScriptTips.GodWeapon004, Actor.getName(sysarg), typeCfg.name)
    	System.broadcastTipmsg(noticeStr, ttScreenCenter + ttChatWindow)
	end
	
end

function TestGodWeapon(sysarg)
	HeroGodWeaponLevelUp(sysarg, 1)
end